import request from '../../utils/request';

// 会员等级管理相关 API

// 根据消费金额获取会员等级
export const getMemberLevelByConsumptionAmount = (consumptionAmount: number) => {
    return request({
        url: `/member/api/member-level/by-consumption-amount/${consumptionAmount}`,
        method: 'get'
    });
};

// 根据成长值获取会员等级
export const getMemberLevelByGrowthValue = (growthValue: number) => {
    return request({
        url: `/member/api/member-level/by-growth-value/${growthValue}`,
        method: 'get'
    });
};

// 创建会员等级
export const createMemberLevel = (data: any) => {
    return request({
        url: '/member/api/member-level/create',
        method: 'post',
        data
    });
};

// 删除会员等级
export const deleteMemberLevel = (id: string) => {
    return request({
        url: `/member/api/member-level/delete/${id}`,
        method: 'delete'
    });
};

// 获取会员等级详情
export const getMemberLevelDetail = (id: string) => {
    return request({
        url: `/member/api/member-level/detail/${id}`,
        method: 'get'
    });
};

// 获取启用的会员等级列表
export const getEnabledMemberLevels = () => {
    return request({
        url: '/member/api/member-level/list/enabled',
        method: 'get'
    });
};

// 分页查询会员等级
export const getMemberLevelPage = (params: any) => {
    return request({
        url: '/member/api/member-level/page',
        method: 'get',
        params
    });
};

// 更新会员等级
export const updateMemberLevel = (data: any) => {
    return request({
        url: '/member/api/member-level/update',
        method: 'put',
        data
    });
};
